--[[
    串口接收数据并打印出来，应用层自己定义串口协议，注意不要以 AA 55 做串口协议的标志
--]]
-------------------模块区-------------------
local logger = require("dx_logger")
local queue = require("dx_queue")
local channel = require("dx_channel")

-------------------变量区-------------------
local read_queue = _G.channel_read_queue
local write_queue = _G.channel_write_queue

-------------------函数区-------------------

local function main()
    while true do
        local data = queue.pop(read_queue, 0)
        if (data == nil) then
            os.execute("sleep 1")
        else
            --把接收到的数据再输出回去
            queue.push(write_queue, data, 500)
        end
    end
end

-------------------主流程-------------------
main()
